<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444">分数线变化分析</h2>
    <div class="clearfix back_bgf border_3 border_c pr30 pt20 pb20 height32 fontc_666">
        <form class="clearfix pb10">
            <table>
                <tbody>
                    <tr>
                        <td width="87" align="right" class="pt10 pr2">考试项目：</td>
                        <td width="250" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" id="exam_id" name="exam_id">
                                        <option value="">请选择</option>
                                        <?php
                                        if (!empty($examArray)):
                                            foreach ($examArray as $eVal):
                                                ?>
                                                <option value="<?php echo $eVal['exam_id']; ?>"><?php echo $eVal['exam_term_name']; ?></option>
                                                <?php
                                            endforeach;
                                        endif;
                                        ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td width="87" align="right" class="pt10 pr2">类别：</td>
                        <td width="250" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" id="subject_type" name="subject_type">
                                        <option value="0">请选择</option>
                                        <option value="1">理科</option>
                                        <option value="2">文科</option>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td width="90" align="right" class="pt10">
                            <input type="button" value="统计" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" id="tongji" />
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="pt10 pr2">在籍人数：</td>
                        <td class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" name="member_ship" id ="member_shp">
                                        <!--<option value="">请选择</option>-->
                                        <?php if (!empty($memberShip)): ?>
                                            <?php foreach ($memberShip as $mVal): ?>
                                                <option value="<?php echo $mVal['membership_id']; ?>"><?php echo $mVal['membership_name']; ?></option>
                                            <?php endforeach; ?>
                                        <?Php endif; ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td align="right" class="pt10 pr2">统计方式：</td>
                        <td colspan="2" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" id="ptype" name="type">
                                      
                                        <option value="1">总人数</option>
                                        <option value="2">增加人数</option>
                                    </select>
                                </span>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" class="pt10 pr2">选择学校：</td>
                        <td colspan="4" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter">
                                    <select class="fl fontc_666" id="school_code" name="school_code">
                                        <option value="">请选择</option>
                                        <?php
                                        if (!empty($schoolObject)):
                                            foreach ($schoolObject as $sVal):
                                                ?>
                                                <option value="<?php echo $sVal['school_code']; ?>"><?php echo $sVal['school_name']; ?></option>
                                                <?php
                                            endforeach;
                                        endif;
                                        ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" value="新增" style="margin-right:30px;" id="add" class="cursor fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12" />
            <input type="button" value="删除" onclick="delete_all()" class="fl b_a_n border_3 back_bgfb w80 ml20 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                    	<th width="70" align="center" class="m_hr_t m_hr_b pr30 pl10"><input type="checkbox" class="checkboxs"></th>
                        <th width="270" align="center" class="m_hr_t m_hr_b">序号</th>
                        <th width="278" align="center" class="m_hr_t m_hr_b">分差</th>
                        <th width="110" align="center" class="m_hr_t m_hr_b pl30">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                <?php if (!empty($chagePoint)): ?>
                    <?php foreach ($chagePoint as $value): ?>
                    <tr>
                    	<td align="center" class="m_hr_b pr30 pl10"><input type="checkbox" name="deleteAll[]" value="<?php echo $value['pd_id'];?>" class="checkbox"></td>
                        <td align="center" class="m_hr_b"><?php echo $value['pd_id']; ?></td>
                        <td align="center" class="m_hr_b pt8 pb8 height24"><?php echo $value['membership_name']; ?></td>
                        <td align="center" class="m_hr_b pl30">
                            <a href="javascript:;" class="edit mr10" pid="<?php echo $value['pd_id']; ?>" title="编辑"><img src="/themes/default/images/Sipei/edit.png" /></a>
                            <a href="javascript:;" class="del" pid="<?php echo $value['pd_id']; ?>" title="删除"><img src="/themes/default/images/Sipei/delate.png" /></a>
                        </td>
                    </tr>
                        <?php
                    endforeach;
                else:
                    ?>
                    <tr>
                        <td align="center" class="m_hr_b" colspan="4">暂时没有数据</td>
                    </tr>
                <?php endif; ?>
                </tbody>
            </table>
        </form>
    </div>
</div>
<script>
    $(function(){
        $("#add").click(function(){
            api = $.dialog({
                 id: 'testID2',
                 lock: true,
                 padding:0,
                 fixed: true,
                 title:"新增",
                 width:480,
                 height:160,
                 max: false,
                 min: false
             });

             $.get('/change_scores/default/add',{},function(html){
                 api.content(html);
             });
        });
        $(".edit").click(function(){     
            var pid = $(this).attr('pid');
            api = $.dialog({
                 id: 'testID2',
                 lock: true,
                 padding:0,
                 fixed: true,
                 title:"编辑",
                 width:480,
                 height:160,
                 max: false,
                 min: false
             });

             $.get('/change_scores/default/update',{pid:pid,time:new Date()},function(html){
                 api.content(html);
             });
        });
        $(".del").click(function(){
            var pid = $(this).attr('pid');
            var that = $(this);
            $.dialog.confirm('确定删除吗',function(){
                $.get('/change_scores/default/delete',{pid:pid,time:new Date()},function(html){
                    if(html==1){
                        that.parents('tr').remove();
                    }
                    api.content(html);
                });
            });
        });
        
        $("#tongji").click(function(){
            var exam_id = $("#exam_id").val();      //考试
            var type = $("#subject_type").val();    //科目
            var mp = $("#member_shp").val();        //科别
            var ptype = $("#ptype").val();          //类型
            var school_code = $("#school_code").val();  //学校
            
            var url = '<?php echo $this->createUrl('/change_scores/default/list'); ?>';
            if(exam_id>0){
                window.open(url+"/exam_id/"+exam_id+"/school_code/"+school_code+"/type/"+type+"/mp/"+mp+"/ptype/"+ptype);
            }else{
                $.dialog.alert("请选择考试项目");
            }
        });
        
        //全选
        $(".checkboxs").click(function() {
            var checkedS = $(this).attr("checked");
            if (checkedS) {
                $(".checkbox").attr("checked", true)
            } else {
                $(".checkbox").removeAttr("checked")
            }
        });
        
        //根据考试得到学校
        $("#exam_id").change(function(){
            
            var exam_id = $(this).val();
            if(exam_id>0){
                $.get('/change_scores/default/ajax_get_school',{exam_id:exam_id},function(list){
                    $("#school_code").html(list);
                }); 
            }
        });
        
    });
    
    //批量删除
    function delete_all(){
        var aa='';
        $("input[name='deleteAll[]']:checkbox:checked").each(function(){
            aa+=$(this).val()+',';
        });
        if(aa == ''){
            $.dialog.alert("请选择要删除条目");
            return false;
        }
        $.dialog.confirm('确定删除所选数据吗', function() {
            aa+=0;
            $.get('/change_scores/default/delete_all', {id: aa}, function(data) {
                location.reload();
            });
        });
    }
    
</script>